package com.tengju.user.domain.model.archive.letax;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.tengju.user.domain.shared.DomainException;
import com.tengju.user.domain.shared.DomainExceptionCode;

public enum IdentityType {

    NO_IDENTITY("no_identity", 1),
    PERSON("person", 2),
    REGISTER_SOHO("regist_soho", 3),
    CERTIFIED_BUSINESS("certified_business", 4),
    CERTIFIED_INDIVIDUAL("certified_individual", 5),
    ;

    private String val;
    private int accountType;

    IdentityType(String val, int accountType) {
        this.val = val;
        this.accountType = accountType;
    }

    public String getVal() {
        return val;
    }

    public int getAccountType() {
        return accountType;
    }

    @JsonCreator
    public static IdentityType fromVal(String val) {
        IdentityType identityType = null;
        for (IdentityType data : values()) {
            if (data.val.equals(val)) {
                identityType = data;
            }
        }
        return identityType;
    }

    public static IdentityType fromAccountType(int accountType) {
        IdentityType identityType = null;
        for (IdentityType data : values()) {
            if (data.accountType == accountType) {
                identityType = data;
            }
        }
        return identityType;
    }

}
